package legumes.client.ui;

import legumes.shared.domain.CustomerDTO;

/**
 * A special cookie is used to keep the email of the customer locally. This
 * cookie, even if sent to the server, is not used by server. We could say it is
 * a local cookie.
 * 
 * It is important to know that GWT works with a session cookie that stores the
 * identifier of the session (JSESSIONID). This is the JESSIONID cookie that
 * allows the server to recognize the connected customers through RPC calls.
 * 
 * CustomerID cookie and JSESSIONIS cookie shall have the same lifecycle.
 * 
 * When JSESSIONID cookie exists, it means that the client is still connected.
 * Then, CustomerID still exists also, so the client can display the email of
 * the client without asking it to the server.
 * 
 * @author cpipo
 * 
 */
public class Authentication {
	private static CustomerDTO customer;

	public static CustomerDTO getCustomer() {
		return customer;
	}

	public static void setCustomer(CustomerDTO customer_) {
		customer = customer_;
	}

	public static boolean isAuthenticated() {
		return getCustomer() != null;
	}

}
